package com.cms.intelligent_control.common.websocket

class SimpleCallback : WebSocketCallback {

    private var _onOpen: (() -> Unit)? = null

    fun onOpen(listener: () -> Unit) {
        _onOpen = listener
    }

    override fun onOpen() {
        _onOpen?.invoke()
    }

    private var _onMessage: ((msg: String) -> Unit)? = null

    fun onMessage(listener: (msg: String) -> Unit) {
        _onMessage = listener
    }

    override fun onMessage(text: String) {
        _onMessage?.invoke(text)
    }
}